<%@page import="entityBeans.Contact"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Contact Profile</title>
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
</head>
<body>
	<!-- Header -->
	<div class="container">
		<br />
		<h1 class="text-center">Major Donut Outbreak Consequences</h1>
		<br />
	</div>
	<!-- Header end-->

	<div class="container">
		<!-- Top navigation bar -->
		<div class="navbar alert-success col-md-12" role="navigation">
			<ul class="nav navbar-nav navbar-right">
				<li class="alert-info"><a href="#normal" data-toggle="tab"><span
						class="glyphicon glyphicon-check"></span> Normal view</a></li>
				<li class="alert-success"><a href="#edit" data-toggle="tab">
						<span class="glyphicon glyphicon-cog"></span> Edit
				</a></li>
			</ul>
		</div>
	</div>
	<div class="container">

		<c:if test="${param.lastupdatefailed == 'true' }">
			<div class="panel panel-default">
				<div class="panel-body alert-danger text-center">
					<p>Last update failed because someone modified the contact
						before you</p>
				</div>
			</div>
		</c:if>

		<!-- End top navigation bar -->
		<!-- Middle containers -->
		<div class="tab-content">
			<div class="tab-pane active" id="normal">
				<div class="panel panel-success">
					<div class="panel-heading">Contact profile</div>
					<div class="panel-body col-md-12 text-center">
						<div class="col-md-6">
							<table class="table table-bordered">
								<!-- Contact info -->
								<tr>
									<td colspan="2" class="alert-info">Contact information</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Firstname</td>
									<td class="col-sm-9 text-left">${Contact.firstName}</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Lastname</td>
									<td class="col-sm-9 text-left">${Contact.lastName}</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Email</td>
									<td class="col-sm-9 text-left">${Contact.email}</td>
								</tr>
								<c:if test="${param.ctype == 'company'}">
									<tr>
										<td class="col-sm-3 control-label text-right">Num Siret</td>
										<td class="col-sm-9 text-left">${Contact.numSiret}</td>
									</tr>
								</c:if>
								<!-- Contact address -->
								<tr>
									<td colspan="2" class="alert-info">Address</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Street</td>
									<td class="col-sm-9 text-left">${Contact.add.street}</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">City</td>
									<td class="col-sm-9 text-left">${Contact.add.city}</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Zip</td>
									<td class="col-sm-9 text-left">${Contact.add.zip}</td>
								</tr>
								<tr>
									<td class="col-sm-3 control-label text-right">Country</td>
									<td class="col-sm-9 text-left">${Contact.add.country}</td>
								</tr>
							</table>
						</div>
						<div class="col-md-6">
							<table class="table table-bordered">
								<!-- Contact phones -->
								<tr>
									<td colspan="2" class="alert-info">Phone numbers</td>
								</tr>
								<c:forEach items="${CPhones}" var="phone">
									<tr>
										<td class="col-sm-3 control-label text-right">${phone.phoneKind}</td>
										<td class="col-sm-9 text-left">${phone.phoneNumber}</td>
									</tr>
								</c:forEach>
							</table>

							<table class="table table-bordered">
								<tr>
									<td class="alert-info">Groups</td>
								</tr>
							</table>

							<ul class="list-group pre-scrollable">
								<c:forEach items="${Contact.books}" var="group">
									<li class="list-group-item">${group.groupName}</li>
								</c:forEach>
							</ul>
						</div>
					</div>
				</div>
			</div>


			<!-- Edit pane -->
			<div class="tab-pane fade" id="edit">
				<form class="form-vertical" method="post" action="UpdateContact">
					<div class="panel panel-success">
						<div class="panel-heading">Contact profile</div>
						<div class="panel-body col-md-12 text-center">
							<div class="col-md-6">
								<table class="table table-bordered">
									<!-- Contact info -->
									<tr>
										<td colspan="2" class="alert-info">Contact information</td>
									</tr>
									<tr>
										<td class="col-sm-3 form-label text-right">Firstname</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="firstname"
											value="${Contact.firstName}" required></td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">Lastname</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="lastname"
											value="${Contact.lastName}" required></td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">Email</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="email" name="email"
											value="${Contact.email}" required></td>
									</tr>
									<c:if test="${param.ctype == 'company'}">
										<tr>
											<td class="col-sm-3 control-label text-right">Num Siret</td>
											<td class="col-sm-9 text-left"><input
												class="form-control col-sm-12" type="text" name="numsiret"
												value="${Contact.numSiret}" required></td>
										</tr>
									</c:if>
									<!-- Contact address -->
									<tr>
										<td colspan="2" class="alert-info">Address</td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">Street</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="street"
											value="${Contact.add.street}" required></td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">City</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="city"
											value="${Contact.add.city}" required></td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">Zip</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="zip"
											value="${Contact.add.zip}" required></td>
									</tr>
									<tr>
										<td class="col-sm-3 control-label text-right">Country</td>
										<td class="col-sm-9 text-left"><input
											class="form-control col-sm-12" type="text" name="country"
											value="${Contact.add.country}" required></td>
									</tr>
								</table>
							</div>
							<div class="col-md-6">

								<table class="table table-bordered">
									<!-- Contact phones -->
									<tr>
										<td colspan="2" class="alert-info">Phone numbers</td>
									</tr>
									<c:forEach items="${CPhones}" var="phone">
										<tr>
											<td class="col-sm-3 control-label text-right">${phone.phoneKind}</td>
											<td class="col-sm-9 text-left"><input
												class="form-control col-sm-12" type="text"
												name="tel_${phone.phoneKind}" value="${phone.phoneNumber}" /></td>
										</tr>
									</c:forEach>
								</table>

								<table class="table table-bordered">

									<tr>
										<td class="alert-info">Groups</td>
									</tr>
								</table>

								<ul class="list-group pre-scrollable">
									<c:forEach items="${ContactGroups}" var="group">
										<c:choose>
											<c:when test="${group.value}">
												<li class="list-group-item"><label class="pull-left">
														<input type="checkbox" value="${group.key.id}"
														name="contactgroups${group.key.id}" checked>
												</label>${group.key.groupName}</li>
											</c:when>
											<c:otherwise>
												<li class="list-group-item"><label class="pull-left">
														<input type="checkbox" value="${group.key.id}"
														name="contactgroups${group.key.id}">
												</label>${group.key.groupName}</li>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</ul>

								<button class="btn btn-success" type=submit>Save
									changes</button>
							</div>
							<input type="hidden" name="ctype" value="${param.ctype}" /> <input
								type="hidden" name="version" value="${Contact.version}" /> <input
								type="hidden" name="id" value="${Contact.id}" />
				</form>
			</div>
		</div>
	</div>
	</div>
	</div>
	<!-- End middle containers -->
	<!-- Bottom navigation bar -->
	<div class="container">
		<div class="navbar alert-success col-md-12" role="navigation">
			<ul class="nav navbar-nav navbar-right">
				<li><a href="LoadContacts">Back to main page</a></li>
			</ul>
		</div>
	</div>
	<!-- End bottom navigation bar -->
	<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
	<script src="js/bootstrap.js"></script>
</body>
</html>